package com.aisile.manager.controller;

import com.aisile.entity.PageResult;
import com.aisile.entity.Result;
import com.aisile.pojo.TbSpecification;
import com.aisile.pojogroup.Specifacation;
import com.aisile.sellergoos.service.SpecificationService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("specification")
public class SpecificationController {
    @Reference
    SpecificationService specificationService;
    @RequestMapping("findPage")
    public PageResult findPage(int page, int rows,@RequestBody TbSpecification tbSpecification){
        return specificationService.findPage(page,rows,tbSpecification);
    }

    @RequestMapping("save")
    public Result save(@RequestBody Specifacation specifacation){
        try {
            specificationService.save(specifacation);
            return new Result(true,"");
        }catch (Exception e){
            return new Result(false,"服务器崩溃了");
        }
    }

    @RequestMapping("findOne")
    public Specifacation findOne(long id){
       return specificationService.findOne(id);
    }

    @RequestMapping("update")
    public Result update(@RequestBody Specifacation specifacation){
        try {
            specificationService.update(specifacation);
            return new Result(true,"");
        }catch (Exception e){
            return new Result(false,"服务器崩溃了");
        }
    }

    @RequestMapping("del")
    public Result del(Long[] ids){
        try {
            specificationService.del(ids);
            return new Result(true,"");
        }catch (Exception e){
            return new Result(false,"服务器崩溃了");
        }
    }



}
